<template>
<div>
  <div class="look animated fadeInUp" >
    <img class="title" src="../assets/img/title.png">
    <div class="message">
      <img v-if="imgUrl" :src="imgUrl">
    </div>
    <div class="addr">
      <span class="from">from</span>
      <span class="avatar">
        <img :src="userImg">
      </span>
      <span>{{name}}</span>
    </div>
    <img @click="gotoHome" class="diff animated swing"   src="../assets/img/diff.png"/>
  </div>
</div>
</template>

<script>
import coding from '../assets/js/coding.js'
export default {
  name: 'Success',
  data () {
    return {
      imgUrl: '',
      showMask: false,
      userId: '',
      name: '',
      userImg: '',
      confessionId: ''
    }
  },
  mounted () {
  //  let url = "http://192.168.66.102:8081/#/null?userId=18&confessionId=1ceeb51b7aa945e4800b61ae2b572bbd"
  //  let arr =  url.split('?')[1].split('&')
    let arr = document.location.href.split('null?')[1].split('&')
    arr.forEach((v, item) => {
      if (v.split('=')[0] === 'userId') {
        this.userId = v.split('=')[1]
      }
      if (v.split('=')[0] === 'confessionId') {
        this.confessionId = v.split('=')[1]
      }
    })
    let objData = {
      userId: this.userId,
      confessionId: this.confessionId
    }
    this.axios({
      method: 'get',
      url: 'http://211.149.169.49:8080/confession/user/getUserById.do',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
      },
      data: objData,
      params: objData
    }).then(res => {
      // 对图像进行解码
      var base = new coding.Base64()
      let decodeCanvasImgUrlEd = base.decode(res.data.data.confessionImg)
      this.imgUrl = decodeCanvasImgUrlEd
      this.userImg = res.data.data.userImg || 'http://www.qq22.com.cn/uploads/allimg/c170101/14S24020O0430-133M2.jpg'
      this.name = res.data.data.userName
    })
  },
  methods: {
    gotoHome () {
      window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb9bc588f403c0a6f&redirect_uri=http%3A%2F%2Fctans.com%2Fdist%2Fceshi.html&response_type=code&scope=snsapi_userinfo&state=#wechat_redirect'
    },
    onShowMask () {
      this.showMask = !this.showMask
    }
  }
}
</script>
<style  @scoped lang="less">
    .look{
      text-align: center;
      width: 100%;
      .title{
        width: 4.5rem;
        margin: 0 auto;
        padding-top: 1rem;
        padding-bottom: .6rem;
        height: 1.2rem;
      }
      .message{
        width: 4rem;
        background: url(../assets/img/message.png);
        background-size: 100% 100%;
        height: 4rem;
        margin: 0 auto;
        margin-bottom: .4rem;
        padding: 1.4rem .3rem .3rem .3rem;
      }
      .addr{
        display: flex;
        align-items: center;
        justify-content: flex-end;
        width: 5rem;
        margin: 0 auto;
        font-size: .2rem;
        .from{
          display: inline-block;
          margin-right: .2rem;
        }
        .avatar{
          display: inline-block;
          width: .95rem;
          margin-right: .2rem;
          height: .95rem;
          border-radius: .91rem;
          border: .01rem solid #DA3615;
          padding: .05rem;
          img{
            width: .95rem;
            height: .95rem;
            border-radius: .95rem;
          }
        }
      }
    }
     .diff{
        width: 2.63rem;
        height: .84rem;
        margin: 0 auto;
        margin-top: .1rem;
        -webkit-animation-name:pulse2;
        animation-name:pulse2;
        animation-duration: 1s;
        animation-iteration-count: infinite;
      }
      @-webkit-keyframes pulse2{
        0%{-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}
        15%{-webkit-transform:scale3d(1.05,1.05,1.05);transform:scale3d(1.05,1.05,1.05)}
        50%{-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}
        100%{-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}
      }
      @keyframes pulse2{
        0%{-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}
        15%{-webkit-transform:scale3d(1.05,1.05,1.05);transform:scale3d(1.05,1.05,1.05)}
        50%{-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}
        100%{-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}
      }

    </style>
